package com.aaa.maintain.service.impl;

import com.aaa.entity.MainShop;
import com.aaa.maintain.dao.MainShopDao;
import com.aaa.maintain.service.MainShopService;
import com.aaa.vo.Result;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 荆豪峰
 * @version 1.0
 * #Date: 2023/3/1 10:16
 */
@Service
public class MainShopServiceImpl extends ServiceImpl<MainShopDao, MainShop> implements MainShopService {
    @Autowired
    private MainShopDao mainShopDao;
    @Override
    public Result list(Integer currentPage, Integer pageSize, MainShop mainShop) {
        QueryWrapper<MainShop> wrapper = new QueryWrapper<>();
        wrapper.like(mainShop.getName()!=null,"name",mainShop.getName());
        PageHelper.startPage(currentPage, pageSize);
        List<MainShop> sysDictTypes = mainShopDao.selectList(wrapper);
        PageInfo<MainShop> sysDictTypePageInfo = new PageInfo<>(sysDictTypes);
        return new Result(2000,"成功",sysDictTypePageInfo);

    }

    @Override
    public Result insert(MainShop mainShop) {
        int insert = mainShopDao.insert(mainShop);
        return new Result(2000,"添加成功",insert);
    }

    @Override
    public Result delete(Integer id) {
        int i = mainShopDao.deleteById(id);
        return new Result(2000,"成功",i);
    }

    @Override
    public Result update(MainShop mainShop) {
        int i = mainShopDao.updateById(mainShop);
        return new Result(2000,"修改成功",i);
    }
}
